#!/usr/bin/expect
set v_passwd "*assword:"
set timeout 8
set user_name  root 
set host_ip    192.168.31.130 
set user_passwd j
spawn ssh -l $user_name $host_ip 
expect {
    "*assword:"    
    {
        send "$user_passwd\r"
    }
    "*yes/no*"    
    {
        send "yes\r"
        exp_continue
    }
    "Last login*" #if ssh can login without passwd
    {

    }
}
        send "poweroff\r"

        set host_ip    192.168.31.131 
set user_passwd j
spawn ssh -l $user_name $host_ip 
expect {
    "*assword:"    
    {
        send "$user_passwd\r"
    }
    "Last login*" #if ssh can login without passwd
    {

    }
}
        send "poweroff\r"

    set host_ip    192.168.31.132 
set user_passwd j
spawn ssh -l $user_name $host_ip 
expect {
    "*assword:"    
    {
        send "$user_passwd\r"
    }
    "Last login*" #if ssh can login without passwd
    {

    }
}
        send "poweroff\r"


    set host_ip    192.168.31.133 
set user_passwd j
spawn ssh -l $user_name $host_ip 
expect {
    "*assword:"    
    {
        send "$user_passwd\r"
    }
    "Last login*" #if ssh can login without passwd
    {

    }
}
        send "poweroff\r"


interact
